// router路由页面
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '控制中心', icon: 'dashboard' }
    }]
  },

  {
    path: '/meetingAnalysis',
    component: Layout,
    redirect: '/meetingAnalysis/storyLine',
    name: 'meetingAnalysis',
    meta: { title: '会议分析', icon: 'el-icon-data-line' },
    children: [
      {
        path: 'storyLine',
        name: 'storyLine',
        component: () => import('@/views/meetingAnalysis/storyLine'),
        meta: { title: '会议概括' }
      },
      {
        path: 'speakAnalysis',
        name: 'speakAnalysis',
        component: () => import('@/views/meetingAnalysis/speakAnalysis'),
        meta: { title: '发言分析' }
      }
    ]
  },
  // {
  //   path: '/analysis',
  //   component: Layout,
  //   redirect: 'analysis/speak'
  //   name: 'Analysis',
  //   meta: { title: '会议分析', icon: 'el-icon-s-help'},
  //   children: [
  //   ]
  // },
  {
    path: '/meetings',
    component: Layout,
    redirect: '/meetings/index',
    name: 'meetings',
    meta: { title: '会议管理', icon: 'el-icon-files' },
    children: [
      {
        path: 'index',
        name: 'meetings',
        component: () => import('@/views/meetings/index'),
        meta: { title: '会议列表' }
      },
      {
        path: 'calendar',
        name: 'calendar',
        component: () => import('@/views/meetings/Calendar'),
        meta: { title: '会议日程' }
      }
    ]
  },
  {
    path: '/meetingupload',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'meetingUpload',
        component: () => import('@/views/meetingUpload/index'),
        meta: { title: '会议上传', icon: 'el-icon-upload2' }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/info',
    name: 'user',
    meta: { title: '用户中心', icon: 'el-icon-user' },
    children: [
      {
        path: 'info',
        name: 'info',
        component: () => import('@/views/user/info'), // Parent router-view
        meta: { title: '用户信息' }
      },
      {
        path: 'changepassword',
        name: 'changepassword',
        component: () => import('@/views/user/changepassword'),
        meta: { title: '更改密码' }
      }
    ]
  },
  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: '外部链接', icon: 'link' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
